package leetcode;

/**
 * description:
 * author:zt
 * date:2021-09-11
 */
public class leetcode137 {
    public int singleNumber(int[] nums) {
        int ans = 0;
        for (int i = 0; i < 32; i++) {
            int total = 0;
            for (int num : nums) {
                total += ((num>>i)&1); // 取出num这个数字的第i位
            }
            if (total%3 != 0) ans |= (1<<i);  //如果该位是1 出现一次的数字该位就是1
        }
        return ans;
    }
}
